<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<{include file='backend/lib/meta.html'}>
<link rel="stylesheet" type="text/css" href="public/theme/backend/css/verydows.css" />
<link rel="stylesheet" type="text/css" href="public/theme/backend/css/main.css" />
<link rel="stylesheet" type="text/css" href="public/theme/backend/css/datetimepicker.css"/>
  <style type="text/css">
    .poiner{cursor: pointer}
  </style>
<script type="text/javascript" src="public/script/jquery.js"></script>
<script type="text/javascript" src="public/theme/backend/js/verydows.js"></script>
<script type="text/javascript" src="public/theme/backend/js/list.js"></script>
<script type="text/javascript">
$(function(){
  searchRes(1);
  
  $('#start_date').datetimepicker ({
    format:'Y-m-d',
    formatDate: 'Y-m-d',
    allowBlank:true,
    onShow:function(ct){
      this.setOptions({maxDate:$('#end_date').val()? $('#end_date').val():false})
    }, timepicker:false
  });
  $('#end_date').datetimepicker ({
    format:'Y-m-d',
    formatDate: 'Y-m-d',
    allowBlank:true,
    onShow:function(ct){
      this.setOptions({minDate:$('#start_date').val()? $('#start_date').val():false})
    }, timepicker:false
  });

});

function searchRes(page_id){
  var dataset = {
    status:$('#order_status').val(),
    order_id:$('#order_id').val(),
    start_date: $('#start_date').val(),
    end_date: $('#end_date').val(),
    page:page_id,
    pernum: 10,
  };
  
  $.asynList("<{url m=$MOD c='order' a='tixian' step='search'}>", dataset, function(data){
    if(data.status == 'success'){
      $("#amount").text(data.amount);
      $('#rows').append(juicer($('#table-tpl').html(), data));
      $('#rows tr').vdsRowHover();
      $('#rows tr:even').addClass('even');
      if(data.paging != null) $('#rows').append(juicer($('#paging-tpl').html(), data));
    }else{
      $('#rows').append("<div class='nors mt5'>未找到相关数据记录...</div>");	
    }     
  });
}

function pageturn(page_id){searchRes(page_id);}

function daochuRes(){
  var start_date = $('#start_date').val();
  var end_date = $('#end_date').val();
  var order_status = $('#order_status').val();
  var url = "/index.php?m=backend&c=order&a=export_excel_tixian&start_date=" + start_date + '&end_date=' + end_date + '&order_status=' + order_status;
  window.location.href = url;
}
</script>
</head>
<body>
<div class="content">
  <div class="loc"><h2><i class="icon"></i>提现列表</h2></div>
  <div class="box">
    <div class="doacts">
      <!--<a class="ae btn" href="<{url m=$MOD c='order' a='export_excel_tixian'}>"><i class="remove"></i><font>导出</font></a>-->

      <a class="ae btn" href="#" onclick="daochuRes()"><i class="remove"></i><font>导出</font></a>

    </div>
    <div class="stools mt5">
      <select id="order_status" class="slt">
        <option value="" selected="selected">状态</option>
        <option disabled="disabled">-------------------</option>
        <option value="0">失败</option>
        <option value="1">成功</option>
        <option value="2">申请中</option>
      </select>
      <input value="" class="date w100 txt" id="start_date" type="text" placeholder="开始日期" />
      <input value="" class="date w100 txt" id="end_date" type="text" placeholder="截止日期" />
      <!--<input type="text" class="w300 txt" id="order_id" placeholder="输入订单号" />-->
      <button type="button" class="sbtn btn" onclick="searchRes(1)">搜 索</button>
    </div>
    <div class="module mt5" id="rows"></div>
  </div>
</div>
<script type="text/template" id="table-tpl">
<form method="post" id="mulentform">
  <table class="datalist">
    <tr>
      <th width="60" colspan="2">编号</th>
      <th width="150">用户</th>
      <th width="100">提现金额</th>
      <th width="130">提现状态</th>
      <th class="ta-l">提现时间</th>
      <th class="ta-l">操作</th>
    </tr>
    {@each list as v}
    <tr>
      <td width="20"><input name="id[]" type="checkbox" value="${v.order_id}" /></td>
      <td width="40">${v.id}</td>
      <td>${v.username}</td>
      <td>$${v.money} - （$${v.money_tax}）</td>
      <td><b class="red" id="text_${v.id}">${v.status_text}</b></td>
      <td>${v.dateline}</td>
      {@if v.status == 2}
      <td class="poiner" id="money_status_${v.id}"><a onclick="set_money(${v.id})" href="javascript:;">设置已打款</a></td>
      {@/if}
    </tr>
    {@/each}
  </table>
</form>
</script>
<{include file='backend/lib/paging.html'}>
<script type="text/javascript">
  function set_money(id){
    /**$.asynList("<{url m=$MOD c='order' a='tixian' step='set'}>", dataset, function(data){
      if(data.status == 'success'){
        $("#money_status_" + id).text('已打款');
      }else{
        alert(data.msg);
        return;
      }
    });**/
    var url = "<{url m=$MOD c='order' a='tixian' step='set'}>";
    var data = "id=" + id;
    $.ajax({
      type: "POST",
      url: url,
      cache: false,
      async: true,
      data: data,
      dataType : "json",
      success: function (res) {
        if(res.status == 'success'){
          $("#money_status_" + id).text('已打款');
          $("#text_" + id).text('已打款');
        }else{
          alert(res.msg);
          return;
        }
      }
    });
  }
</script>
<script type="text/javascript" src="public/script/juicer.js"></script>
<script type="text/javascript" src="public/theme/backend/js/datetimepicker.js"></script>
</body>
</html>